]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
endSessionDialog: Factor out _updateDescription from _updateContent
authorAlejandro Piñeiro <apinheiro@igalia.com>
Tue, 5 Jun 2012 09:51:36 +0000 (11:51 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Tue, 5 Jun 2012 13:57:18 +0000 (15:57 +0200)
_startTimer adds a tweener to implement the description countdown, which
updates the entire content on each iteration, including the icon. This
causes a significant impact on performance, especially when accessibility
is enabled, as it causes a flood of AtkObject:state-change:showing events.
As the countdown only affects the description, factor out _updateDescription
and use it in _startTimer, and only do a full update of all contents when
necessary.

https://bugzilla.gnome.org/show_bug.cgi?id=674210

js/ui/endSessionDialog.js

index ee0fc8297f13e7a57b520e1b082166e6eed7dda2..cd6faa17eb3d0b3564f05a50949fee80a1a9901e 100644 (file)
@@ -342,7 +342,7 @@ const EndSessionDialog = new Lang.Class({
         }
     },
 
-    _updateContent: function() {
+    _updateDescription: function() {
         if (this.state != ModalDialog.State.OPENING &&
             this.state != ModalDialog.State.OPENED)
             return;
@@ -352,17 +352,6 @@ const EndSessionDialog = new Lang.Class({
         let subject = dialogContent.subject;
         let description;
 
-        if (this._user.is_loaded && !dialogContent.iconName) {
-            let iconFile = this._user.get_icon_file();
-            if (GLib.file_test(iconFile, GLib.FileTest.EXISTS))
-                this._setIconFromFile(iconFile, dialogContent.iconStyleClass);
-            else
-                this._setIconFromName('avatar-default', dialogContent.iconStyleClass);
-        } else if (dialogContent.iconName) {
-            this._setIconFromName(dialogContent.iconName,
-                                  dialogContent.iconStyleClass);
-        }
-
         if (this._inhibitors.length > 0) {
             this._stopTimer();
             description = dialogContent.inhibitedDescription;
@@ -395,6 +384,27 @@ const EndSessionDialog = new Lang.Class({
         _setLabelText(this._descriptionLabel, description);
     },
 
+    _updateContent: function() {
+        if (this.state != ModalDialog.State.OPENING &&
+            this.state != ModalDialog.State.OPENED)
+            return;
+
+        let dialogContent = DialogContent[this._type];
+
+        if (this._user.is_loaded && !dialogContent.iconName) {
+            let iconFile = this._user.get_icon_file();
+            if (GLib.file_test(iconFile, GLib.FileTest.EXISTS))
+                this._setIconFromFile(iconFile, dialogContent.iconStyleClass);
+            else
+                this._setIconFromName('avatar-default', dialogContent.iconStyleClass);
+        } else if (dialogContent.iconName) {
+            this._setIconFromName(dialogContent.iconName,
+                                  dialogContent.iconStyleClass);
+        }
+
+        this._updateDescription();
+    },
+
     _updateButtons: function() {
         let dialogContent = DialogContent[this._type];
         let buttons = [{ action: Lang.bind(this, this.cancel),
@@ -441,7 +451,7 @@ const EndSessionDialog = new Lang.Class({
                          { _secondsLeft: 0,
                            time: this._secondsLeft,
                            transition: 'linear',
-                           onUpdate: Lang.bind(this, this._updateContent),
+                           onUpdate: Lang.bind(this, this._updateDescription),
                            onComplete: Lang.bind(this, function() {
                                            let dialogContent = DialogContent[this._type];
                                            let button = dialogContent.confirmButtons[dialogContent.confirmButtons.length - 1];